]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
screenShield: Use identity operator when matching for motion events
authorRay Strode <rstrode@redhat.com>
Thu, 8 Oct 2020 13:36:30 +0000 (09:36 -0400)
committerRay Strode <rstrode@redhat.com>
Thu, 8 Oct 2020 13:45:51 +0000 (09:45 -0400)
The screen shield watches for motion events to know to display
the pointer when the user wiggles their mouse.

It checks for motion events by looking at the event type and
seeing if it is of type `Clutter.EventType.MOTION`.  To do this
comparison it uses the equality operator (==).  Using the equality
operator isn't considered best practice, because it can returns true
when comparing disparate types, if those types happen to be equivalent
after coersion.

From a code resiliance point of view, it's better to use the
identity operator (===), which requires both sides of the comparison
to be of the same type.

As a policy, any legacy code that gets changed or moved should be
switched away from the equality operator to the identity operator, if
appropriate.

This commit makes that change as prep work for a fix to that part of
the code.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1459

js/ui/screenShield.js

index b368162ce85c8bc5c13cd317ec2a08dd81854c33..9beece64655ad17e90ff7b4ca196c61eb01de538 100644 (file)
@@ -436,7 +436,7 @@ var ScreenShield = class {
 
     _lockScreenShown(params) {
         let motionId = global.stage.connect('captured-event', (stage, event) => {
-            if (event.type() == Clutter.EventType.MOTION) {
+            if (event.type() === Clutter.EventType.MOTION) {
                 this._cursorTracker.set_pointer_visible(true);
                 global.stage.disconnect(motionId);
             }